import service from "@/request.ts";

interface UserRegisterRequest{
  username: string,
  password: string,
  email: string,
  phone: string,
  code: string
}

export const reqUserRegister = async (params :UserRegisterRequest) => {
  return await service.post('/api/user/register', params);
}

export const reqUserLogin = async (params :any) => {
  return await service.post('/api/user/login', params);
}

export const reqUserCurrent = async () => {
  return await service.get('/api/user/current');
}

export const reqUserLogout = async () => {
  return await service.get('/api/user/logout');
}

export const reqUserDelete = async (id :number) => {
  return await service.request({
    method: 'POST',
    url: '/api/user/delete',
    data: id,
    headers: {
      'Content-Type': 'application/json'
    }
  })
}

export const reqSearchUser = async (username :string) => {
  return await service.request({
    method: 'get',
    url: '/api/user/search',
    params: {
      username: username
    }
  })
}
